package com.tamtamy.jtta.data.json;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.tamtamy.jtta.data.GroupList;
import com.tamtamy.jtta.exception.NoResultException;

public class JSONGroupList extends GroupList {

	private static final long serialVersionUID = 3703204062418258512L;

	public JSONGroupList(JSONObject jsonObject) throws NoResultException{
		super();
		JSONArray groupListJSON = (JSONArray)jsonObject.get("list");
		if (groupListJSON == null || groupListJSON.size()==0){
			throw new NoResultException("No comments found");
		}
		for (int i = 0; i < groupListJSON.size(); i++) {
			JSONObject groupJSON = groupListJSON.getJSONObject(i);
			this.add(new JSONGroupDetails(groupJSON));
		}	
	}
	
}
